package com.readnote.common.action;

import java.util.ArrayList;

import com.cr.backbone.action.AppBaseAction;
import com.cr.backbone.action.AppBaseActionSupport;
import com.cr.backbone.action.LoginInfo;
import com.cr.backbone.intercepter.SessionInterceptKeys;
import com.cr.backbone.model.Menu;
import com.opensymphony.xwork2.ActionContext;
import com.readnote.user.model.User;
import com.readnote.user.model.UserInfo;
import com.readnote.user.service.UserInfoService;
import com.readnote.user.service.UserService;

/**
 * 权限加载
 * @author huxh
 *
 */
public class AdminSecurityAction extends AppBaseActionSupport{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 8751795724091469901L;
	
	private User user;
	private ArrayList<Menu> menus=new ArrayList<Menu>();
	
	
	private UserService userService;
	private UserInfoService userInfoService;
	
	public String index(){
		// 1 
		String title="用户管理";
		String url="../admin/user/index.do";
		addMenus(title, url);
		
		// 2
		addMenus("书籍管理", "../admin/book/index.do");
		addMenus("用户书籍管理", "../admin/userBook/index.do");
		addMenus("笔记管理", "../admin/userNote/index.do");
		addMenus("谏言管理", "../admin/expostulation/index.do");
		addMenus("系统文件管理", "../admin/sysFile/index.do");
		
		
		return INDEX;
	}
	
	public String hello(){
		return "hello";
	}

	private void addMenus(String title,String url){
		
		
		Menu menu=new Menu();
		menu.setTitle(title);
		menu.setUrl(url);
		menus.add(menu);
	}
	
	public void clearMenus() {
		if(menus!=null && !menus.isEmpty() )
			menus.clear();
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public UserInfoService getUserInfoService() {
		return userInfoService;
	}

	public void setUserInfoService(UserInfoService userInfoService) {
		this.userInfoService = userInfoService;
	}

	public ArrayList<Menu> getMenus() {
		return menus;
	}

	public void setMenus(ArrayList<Menu> menus) {
		this.menus = menus;
	}
	
	
	
}
